package t_746

func minCostClimbingStairs(cost []int) int {
	l := len(cost)
	dp := make([]int, l+1)
	for i := 2; i <= l; i++ {
		minLeft := dp[i-1]+cost[i-1] < dp[i-2]+cost[i-2]
		if minLeft {
			dp[i] = dp[i-1] + cost[i-1]
		} else {
			dp[i] = dp[i-2] + cost[i-2]
		}
	}

	return dp[l]
}
